package com.hotel.controller.admin;


import com.hotel.dto.ConsumptionAddDTO;
import com.hotel.service.ConsumptionService;
import com.hotel.result.Result;
import com.hotel.vo.ConsumptionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zxq
 */
@RequestMapping("/consumption")
@RestController
@Api(tags = "消费记录接口")
public class ConsumptionController {
    @Autowired
    private ConsumptionService consumptionService;

    @ApiOperation("添加消费记录")
    @PostMapping
    public Result<String> list(@ApiParam("查询参数") @RequestBody ConsumptionAddDTO consumption){
        consumptionService.saveall(consumption);
        return Result.success("插入成功");
    }

    @ApiOperation("根据入住id查询所有消费记录")
    @GetMapping("/{id}")
    public Result< List<ConsumptionVO>> list(@ApiParam("入住id") @PathVariable Long id){
        List<ConsumptionVO> consumptionVO = consumptionService.getConsumptionByCheckInId(id);
        return Result.success(consumptionVO);
    }
}
